#version 450

layout(location = 0) in vec3 v_normal;
layout(location = 1) in vec4 regular_color;

layout(location = 0) out vec4 f_color;
const vec3 LIGHT = vec3(0.0, 0.0, 1.0); // 0 0 1
const float ABMIENT_RATIO = 0.2;

void main() {
    float brightness = max(dot(normalize(v_normal), normalize(LIGHT)), 0.0);
    vec3 dark_color = vec3(0.5, 0.5, 0.5);
    vec3 regular_color = vec3(regular_color.x, regular_color.y, regular_color.z);
    // brightness is minus?
    // if (brightness <= 0.0) brightness = 0.001; // 添加漫反射
    f_color = vec4(mix(dark_color, regular_color, brightness) + ABMIENT_RATIO * regular_color, 1.0);
    // f_color = vec4(regular_color[0] * brightness,
    // regular_color[1] * brightness,
    // regular_color[2] * brightness,
    // brightness);
}
